/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package nl.maxato.login;

import java.io.File;
import java.net.MalformedURLException;

import nl.maxato.domain.World;
import nl.maxato.xmlservices.ConnectToURL;
import nl.maxato.xmlservices.ConvertXMLData;
import nl.maxato.xmlservices.GetXMLData;
import nl.maxato.xmlservices.XMLService;

/**
 *
 * @author Danny
 */
public class InlogController {
    
	XMLService xmlService;
	
	public InlogController() {
		xmlService = XMLService.getInstance();
	}

    
    public static boolean newVersionAvailable() {
    	return false;
        //return xmlService.newVersionAvailable();
    }
    
    public String signIn(String gebruikersnaam, String wachtwoord) {
        return xmlService.signIn(gebruikersnaam, wachtwoord);
    }

    public boolean checkLogin() {
        return xmlService.checkLogin();
    }

    public String getErrorLogin() {
        return xmlService.getErrorLogin();
    }

    /**
     * Replace spaces in the username with %20 otherwise a username with spaces
     * doesn't work to login and get the XML data.
     * @param username
     * @return usernameWithoutSpaces
     */
    public String checkUsername(String username) {
        String usernameWithoutSpaces = username.replace(" ", "%20");
        return usernameWithoutSpaces;
    }

    public void getDataAthletes(String cookie) {
        xmlService.getDataAthletes(cookie);
    }

    public void getData(String cookie, String typeOfData) {
        xmlService.getData(cookie, typeOfData);
    }

    public World getWorld() {
        return xmlService.worldDataOmzetten();
    }
    
    public void checkIfFoldersExists(String nameFolder) {
        File file = new File(nameFolder);
        boolean exists = file.exists();
        if (!exists) {
            //Create folder is it doesn't exists
            new File(nameFolder).mkdir();
        }
    }
    }
